package com.module.circle.ui.selectDisplayMedal

import android.widget.ImageView
import androidx.constraintlayout.widget.ConstraintLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.common.app.data.bean.circle.CirclesMedalModel
import com.common.base.app.extras.load
import com.common.base.app.extras.otherwise
import com.common.base.app.extras.yes
import com.module.circle.R

/**
 *
 * 作者：sosou
 *
 * 版本：1.0
 *
 * 创建日期：2025/08/14
 *
 * 描述：
 *
 * 修订历史：
 *
 */
class SelectDisplayMedalAdapter : BaseQuickAdapter<CirclesMedalModel, BaseViewHolder>(R.layout.circle_item_select_display_medal_grid_layout) {

    override fun convert(holder: BaseViewHolder, item: CirclesMedalModel) {
        holder.apply {
            (item.id == -999).yes {
                holder.itemView.rootView.alpha = 1f
                getView<ImageView>(R.id.picImg).setImageResource(R.drawable.circle_medal_del_icon)
                setText(R.id.tvName, item.name)
            }.otherwise {
                item.badges?.forEach {
                    (item.current_level == it.level).yes {
                        getView<ImageView>(R.id.picImg).load(it.active_url, 0f)
                        setText(R.id.tvName, it.name)
                        return@forEach
                    }
                }
                holder.itemView.rootView.alpha = if (item.isShowOut) 0.5f else 1f
            }
        }
    }
}